home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / test / blkret.c < prev    next >
C/C++ Source or Header  |  1992-11-23  |  595b  |  53 lines

  1.  
  2. /*
  3.  *  BLKRET.C
  4.  *
  5.  *  test structural returns
  6.  */
  7.  
  8. #include <stdio.h>
  9.  
  10. typedef struct TTest {
  11.     char a, b, c;
  12. } TTest;
  13.  
  14. TTest fubar(TTest, int, volatile int);
  15. TTest xcopy(TTest);
  16.  
  17. int
  18. main(ac, av)
  19. char *av[];
  20. {
  21.     int i1 = 5;
  22.     TTest x, y;
  23.     int i2 = 6;
  24.  
  25.     x.a = 1;
  26.     y.a = 0;
  27.  
  28.     y = xcopy(fubar(x, 23, 46));
  29.     printf("result: %d %d %d\n", y.a, i1, i2);
  30.     return(0);
  31. }
  32.  
  33. TTest
  34. fubar(x, y, z)
  35. TTest x;
  36. int y;
  37. volatile int z;
  38. {
  39.     y;
  40.     printf("expect 1 got %d %d %d\n", x.a, y, z);
  41.     x.a = 4;
  42.     return(x);
  43. }
  44.  
  45. TTest
  46. xcopy(x)
  47. TTest x;
  48. {
  49.     x.a = x.a + 4;
  50.     return(x);
  51. }
  52.  
  53.